local function Fn()
    local Fx = Class()


    function Fx:Init(NPC_BASE_LIB)
        ---------------------------------------------------------------------------------------------------------------------------

        -- if NPC_BASE_LIB.inst == nil or NPC_BASE_LIB.inst:HasTag("player") then
        --     return
        -- end
        function NPC_BASE_LIB:Set_Speed_Mult(num)
            if num and type(num) == "number" and self.inst.components.locomotor and not self.inst:HasTag("player") then
                self.inst.components.locomotor.runspeed = TUNING.WILSON_RUN_SPEED * num
            end
        end

        function NPC_BASE_LIB:GoToPoint(Point,walk_flag)
            if Point.x ~= nil then
                if walk_flag ~= true then
                    -- self.inst.components.locomotor:GoToPoint(Point,nil,true)
                    self:RunToPoint(Point)
                else
                    self:WalkToPoint(Point)
                end
            else
                print("ERROR : NPC_BASE_LIB:GoToPoint(Point) ")
            end
        end

        function NPC_BASE_LIB:RunToPoint(Point)
            if Point.x ~= nil then
                self.inst.components.locomotor:GoToPoint(Point,nil,true)
            else
                print("ERROR : NPC_BASE_LIB:RunToPoint(Point) ")
            end
        end

        function NPC_BASE_LIB:WalkToPoint(Point)
            if Point.x ~= nil then
                self.inst.components.locomotor:GoToPoint(Point,nil,false)
            else
                print("ERROR : NPC_BASE_LIB:WalkToPoint(Point) ")
            end
        end

        function NPC_BASE_LIB:Stop()
            self.inst.components.locomotor:Stop()
            self.inst.components.locomotor:Clear()
            -- self.inst.components.locomotor:ResetPath()

            -- self.inst.Physics:Stop()
            if self.inst.Physics then
                self.inst.Physics:Stop()
                self.inst.Physics:SetMotorVelOverride(0,0,0)
                self.inst.Physics:SetMotorVel(0,0,0)
                self.inst.Physics:ClearMotorVelOverride()
                self.inst.Physics:Stop()
            end
        end

        function NPC_BASE_LIB:FaceToInst(tarInst)
            -- inst:FacePoint(target.Transform:GetWorldPosition())
            local target = tarInst
            if target == nil then
                target = self.inst.__link_player
            end
            if target then
                self.inst:FacePoint(target.Transform:GetWorldPosition())
            end
        end

        function NPC_BASE_LIB:FaceToPoint(Point)
            self.inst:FacePoint(Point.x,Point.y,Point.z)
        end

        function NPC_BASE_LIB:FaceAwayFromPoint(Point,Force_flag)
            self.inst:FaceAwayFromPoint(Point,Force_flag)
        end

        function NPC_BASE_LIB:StackCheck(_range,_num)
            local range = _range or 2
            local num = _num or 4

            local pt = Vector3( self.inst.Transform:GetWorldPosition()  )
            if self.tempData.StackCheck_Last_Point == nil then
                self.tempData.StackCheck_Last_Point = pt
                self.tempData.StackCheck_num = 0
                return false
            end

            if self:Distance_Points(pt,self.tempData.StackCheck_Last_Point) < range then
                self.tempData.StackCheck_num = 1 +  ( self.tempData.StackCheck_num  or 0 )
            else
                self.tempData.StackCheck_num = 0
            end
            self.tempData.StackCheck_Last_Point = pt


            -- print("info : self.tempData.StackCheck_num",self.tempData.StackCheck_num)
            if self.tempData.StackCheck_num >= num then
                return true
            else
                return false 
            end

        end

        ---------------------------------------------------------------------------------------------------------------------------
    end

    return Fx
end

return Fn